<?php

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    class HT_Model_administrator_models_couponcomments extends Zend_Db_Table {//ten class fai viet hoa

        protected $_db;

        public function __construct() {
            $this->_name = "coupon_comments";
            $this->_db = Zend_Registry::get('dbMain');
            parent::init();
        }
        public function getAll($where){
            $sql = "SELECT coupon_comments.* FROM coupon_comments where ".$where;                                    
            $retval = $this->_db->fetchAll($sql);        
            return $retval;
        }                
        public function findById($id){
            $sql = "select * from coupon_comments where id = $id";
            $retval = $this->_db->fetchRow($sql);
            return $retval;
        }        
        public function getcommentfromitem($coupon_id) {            
            $sql = "SELECT coupon_comments.*,user.firstname,user.lastname,user.avatar,user.sex FROM coupon_comments INNER JOIN `user` ON coupon_comments.username = user.user_name WHERE coupon_id = ? ORDER BY `time` DESC";            
            $retval = $this->_db->fetchAll($sql, array($coupon_id));
            return $retval;
        }

    }

?>
